/**
 * Created by chengming on 18/5/27.
 * version 1.0
 */
const BaseJsonAdapter = require('../base/BaseJsonAdapter');
const iconv = require("iconv-lite");
const vm = require('vm');
const request = require('request-promise');
const cheerio = require('cheerio');
const logger = require('../../conf/logger');
const querystring = require("querystring")
const urlencode = require("urlencode")

/**
 */
module.exports = class AliSports extends BaseJsonAdapter{

    async reqJson(){
        const body = await this.doRequest();
        let decodeBody = iconv.decode(body, this.encoding).toString();
        let startStr = 'var olympicData = ';
        let endStr = '}};';
        let startPos = decodeBody.indexOf(startStr) + startStr.length
        let endPos = decodeBody.indexOf(endStr,startPos);
        let jsonData = decodeBody.substr(startPos,endPos - startPos + endStr.length-1);
        let data = JSON.parse(jsonData);
        return data;
	}
}
